package com.wangjie.diffarray;

import java.util.Arrays;

/**
 * @author jieshao
 * @date 2022/4/2 18:03
 *
 * 370. 区间加法
 */
public class Test01 {
    public static void main(String[] args) {
        int[][] arr = {{1, 3, 2}, {2, 4, 3}, {0, 2, -2}};
        int length = 5;
        int[] result = getModifiedArray(length, arr);
        System.out.println(Arrays.toString(result));
    }

    public static int[] getModifiedArray(int length, int[][] update) {
        // 初始化 num 数组，初始值均为 0
        int[] num = new int[length];
        Difference difference = new Difference(num);
        for (int[] t : update) {
            int i = t[0];
            int j = t[1];
            int val = t[2];
            difference.increment(i, j, val);
        }
        return difference.result();
    }
}